import image
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from PIL import Image
import time
from dama import Dama
driver=webdriver.Edge()
driver.get('http://10.59.9.14:7003/')
time.sleep(2)
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
time.sleep(2)
driver.find_element(By.CLASS_NAME,'regi-input').send_keys('13811033962')
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(5)
datu=driver.save_screenshot('datu.png')
time.sleep(2)
yzm=driver.find_element(By.XPATH,'/html/body/div[4]/div/div[1]/div[2]/form/div[3]/span[3]/img')
time.sleep(2)
location=yzm.location
print(location)
size=yzm.size
print(size)

left=location['x']
top=location['y']
regit=left + size['width']
bottom=top + size['height']
image = Image.open('datu.png')
image1= image.crop((left*1.5,top*1.5,regit*1.5,bottom*1.5))
image1.save('image2.png')

dm = Dama('zhangzida123','wnh7oh39','971851')
yzmdm = open('image2.png','rb').read()
jieguo=dm.PostPic(yzmdm,1902)
print(jieguo)
result=jieguo['pic_str']
print('A3MALL项目前台登录的打码结果:',result)

driver.find_element(By.NAME,'code').send_keys(result)

time.sleep(5)

